<template>
    <div :class="{'topBar':true, 'top_Bar_Z': (focusProfile || openPromotion)}">
      <div class="topTitle">
        <el-icon :size="25" :class="{'spanTransition':true,'spanIcon':NavStore.NavState}"><Menu /></el-icon>
        <div style="width: 10%;"></div>
        主页
      </div>
      <div class="topSearch"><searchBar v-model:openPromotion="openPromotion" /></div>
      <div class="informationBar">
        <div :class="{'profileBar':true,'profileBar_hover':focusProfile}" @mouseover="handleMouseOver" @mouseleave="handleMouseLeave">
          <profile :class="{'focusProfile':true,'focusProfile_hover':focusProfile}"></profile>
          <focusProfileBar v-show="focusProfile"></focusProfileBar>
        </div>
      </div>
    </div>
</template>

<script setup>
import searchBar from './searchBar.vue';
import profile from './profile.vue';
import focusProfileBar from './focusProfileBar.vue';
import { Menu } from '@element-plus/icons-vue';
import { showNavState } from '@/stores/showNavState.js'
import { ref } from 'vue'

const focusProfile = ref(false)
const openPromotion = ref(false)

const handleMouseOver = () => {
  focusProfile.value = true
}

const handleMouseLeave = () => {
  focusProfile.value = false
}
const NavStore = showNavState()

</script>

<style scoped>
.topBar{
  height: 8vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* background-color: #a0cfff; */
  border-bottom: 1px solid #79bbff;
  position: fixed;
  top:0;
  z-index: 2;
  transition: all 0.3s ease-in-out;
}
.top_Bar_Z{
  z-index: 4;
}
.topTitle{
  height: 100%;
  width: 6%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 20px;
}
.informationBar{
  height: 100%;
  width: 6%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 2%;
  position:relative;
  right: 15%;
}
.spanIcon{
  transform: rotate(90deg);
}

.focusProfile{
  transition: all 0.4s ease-in-out;
}
.focusProfile_hover{
  transform: scale(1.2);
}


.profileBar{
  position: relative;
  left: 0vh;
  transition: all 0.4s ease-in-out;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.profileBar_hover{
  left: -2vh;
  top:17.5vh;
}



</style>
